luci-mod-status: add `oneshot` handling
authorPaul Spooren <[email protected]>
Thu, 30 Jan 2025 23:33:46 +0000 (23:33 +0000)
committerPaul Donald <[email protected]>
Fri, 11 Apr 2025 12:42:49 +0000 (14:42 +0200)
This allows each include to perform an action a single time but doesn't
run it on each poll (instead running it once per page load). The
function receives all data loaded via the `load` function.

Signed-off-by: Paul Spooren <[email protected]>
modules/luci-mod-status/htdocs/luci-static/resources/view/status/index.js

index da08ec12c27029cbb0595eee906aff106a842b9b..911c187584e56dfa682fabbc4ce830c30131fece 100644 (file)
@@ -40,6 +40,11 @@ function startPolling(includes, containers) {
                                else if (includes[i].content != null)
                                        content = includes[i].content;
 
+                               if (typeof (includes[i].oneshot) == 'function') {
+                                       includes[i].oneshot(results ? results[i] : null);
+                                       includes[i].oneshot = null;
+                               }
+
                                if (content != null) {
                                        containers[i].parentNode.style.display = '';
                                        containers[i].parentNode.classList.add('fade-in');